use aqua::server::prelude::*;
use blog::blog::BlogState;
use blog::route::*;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    utils::init_logger();
    let mut blog_state = BlogState::new();
    blog_state.add_post_of("Hello World".into(), "这是第一篇博客".into(), true);
    blog_state.add_post_of("Draft Post".into(), "未发布内容".into(), false); // 不会显示

    Server::new()
        .mount(router!(home))
        .mount(router!(show_post))
        .mount(router!(admin_dashboard))
        .mount(router!(new_post_page))
        .mount(router!(create_post))
        .mount(router!(edit_page))
        .mount(router!(edit_submit))
        .manage(blog_state)
        .run("127.0.0.1:7878")
        .await?;

    Ok(())
} 

